let os=require('os');
let freemem=os.freemem()
let tmpdir=os.tmpdir()
let totalmem=os.totalmem()
const fs = require("fs");
const cpus = os.cpus()
// console.log(cpus)
// https://zhuanlan.zhihu.com/p/234739164

const {resolve} = require('path')


console.log('__dirname : ' + __dirname)
console.log('resolve   : ' + resolve('./'))
console.log('cwd       : ' + process.cwd())

//__dirname : D:\new\node
//resolve   : D:\new\node
//cwd       : D:\new\node
let cpusStr=JSON.stringify(cpus)

// let  filename = process.argv.splice(2);
const args = process.argv.slice(2)
let  filename = args[0]
console.log("filename");
console.log(filename);
// node 取得参数
// let  filename ="cpu.log"
fs.writeFile(filename, `freemem: ${freemem}  CPU: ${cpusStr}  __dirname 路径: ${__dirname}  ;  总内存 ${totalmem}`, error => {
  if (error) return console.log("写入失败 " + error.message);
  console.log("写入成功");
});
